/*
 * @Description:设备部署
 * @Author: 刘相卿
 * @Company: 山东方亚信息技术有限公司
 * @Date: 2020-09-30 09:09:11
 * @LastEditTime: 2020-11-07 17:07:56
 * @LastEditors: 刘相卿
 */

const Mock = require('mockjs')

let getList = (data) => {
  return Mock.mock({
    'data|10': [
      {
        'id|1': /[a-z][A-Z][0-9]/,
        deployStatus: 0, // 预警状态
        deployTime: '今天10:00:00', // 发生、处理时间
        deviceType: 1, // 预警设备类型
        deployDevice: '美莲广场1楼大厅电气火灾设备', // 设备名称
        deviceNo: '192019375', // 设备编号
      },
    ],
  })
}

let getOverview = (data) => {
  return Mock.mock({
    data: {
      // 未部署
      undeployTotal: 1,
      // 已部署
      deployedTotal: 0,
    },
  })
}

let detail = () => {
  return Mock.mock({
    data: {
      id: 1,
      deviceName: '美莲广场1楼大厅烟感', // 设备名称
      deviceNo: '110120119', // 设备编号
      deployPeople: '张三  18701110988', // 部署联系人
      deployAddress: '济南市高新区铭盛大厦3楼山东方亚信息技术有限公司', // 部署位置
      deviceStatus: {
        sign: 1,
        base: 1,
      }, // 设备状态
      deployDate: '2020-10-09 09:00:00', // 部署时间
      deviceImage:
        'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1602241684371&di=5794bbcf55db914075ddcd61ca8d25e8&imgtype=0&src=http%3A%2F%2Fimage.cn.made-in-china.com%2F2f0j01sCkavEVBbWgb%2F%25E6%25BF%2580%25E5%2585%2589%25E7%25BA%25BF%25E7%25BC%2586%25E5%258A%25A0%25E5%25B7%25A5%25E8%25AE%25BE%25E5%25A4%2587.jpg', // 设备图片
      qrcodeImage:
        'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1602241840297&di=d46e9783371525bfe64aa4ef512d1c2e&imgtype=0&src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F25%2F04%2F20%2F16571d91951a416.jpg', // 设备二维码图片
      envirImage:
        'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1741808,2096056180&fm=26&gp=0.jpg', // 安装环境图片
      latitude: 36.680624, //纬度
      longitude: 117.13403, //经度
      merchantsName: '山东方亚信息技术有限公司（铭盛大厦）',
      buildingCount: 1, // 楼栋数
      floorCount: 23, // 楼层数
      deviceCount: 23, // 设备数
    },
  })
}

module.exports = {
  // 预警处理概览
  [`GET /deploy/overview`](ctx) {
    const { data } = getOverview(ctx.request.body)
    ctx.body = {
      code: 200,
      msg: '操作成功',
      data: data,
    }
  },
  //预警处理列表
  [`GET /deploy/getList`](ctx) {
    const { data } = getList(ctx.request.body)
    ctx.body = {
      code: 200,
      msg: '操作成功',
      data: {
        list: data,
        total: data.length,
        pageSize: 10,
        pageNo: 1,
      },
    }
  },
  // 详情
  [`GET /deploy/detail`](ctx) {
    const data = detail(ctx.request.body)
    ctx.body = {
      code: 200,
      msg: '操作成功',
      data: data,
    }
  },
  // 提交
  [`POST /deploy/confirmDeployment`](ctx) {
    ctx.body = {
      code: 200,
      msg: '操作成功',
      data: '',
    }
  },
}
